#region  == Copyright == 
// =====================================================================
//  Microsoft Consulting Services France - Aymeric Mouillé - 2013
//  Projet     : CRM Solution Management Tool
//  Fichier    : Parameters.cs (30/04/2013 19:10)
//  
//  Copyright (C) Microsoft Corporation.  All rights reserved.
// =====================================================================
#endregion

namespace CRM.Solution.Management.Tool
{
    #region  == Using == 
    using System.ComponentModel;

    using CRM.Solution.Manager.Properties;

    #endregion

    /// <summary>
    /// </summary>
    public class Parameters
    {
        #region Check Interval
        /// <summary>
        /// Gets or sets the check interval.
        /// </summary>
        /// <value>
        /// The check interval.
        /// </value>
        [Description("Check interval between each progress check"), Category("Application settings")]
        public int CheckInterval { get; set; }
        #endregion

        #region Organization Url
        /// <summary>
        /// Gets or sets the organization URL.
        /// </summary>
        /// <value>
        /// The organization URL.
        /// </value>
        [Description("CRM Organization Url"), Category("CRM Connection")]
        public string OrganizationUrl { get; set; }
        #endregion

        #region User Domain
        /// <summary>
        /// Gets or sets the user domain.
        /// </summary>
        /// <value>
        /// The user domain.
        /// </value>
        [Description("User Active Directory domain"), Category("CRM Connection")]
        public string UserDomain { get; set; }
        #endregion

        #region User Login
        /// <summary>
        /// Gets or sets the user login.
        /// </summary>
        /// <value>
        /// The user login.
        /// </value>
        [Description("User Active Directory login"), Category("CRM Connection")]
        public string UserLogin { get; set; }
        #endregion

        #region User Password
        /// <summary>
        /// Gets or sets the user password.
        /// </summary>
        /// <value>
        /// The user password.
        /// </value>
        [Description("User Active Directory password"), Category("CRM Connection")]
        public string UserPassword { get; set; }
        #endregion

        #region Default Export Path
        [Description("Default path for solution export"), Category("Solution Management")]
        public string DefaultExportPath { get; set; }
        #endregion

        #region Crm Connection String
        /// <summary>
        /// Gets or sets the CRM connection string.
        /// </summary>
        /// <value>
        /// The CRM connection string.
        /// </value>
        [Description("Crm Connection String, if specified, overrides other connection settings"), Category("CRM Connection")]
        public string CrmConnectionString { get; set; }
        #endregion

        #region = Constructor =
        /// <summary>
        /// Initializes a new instance of the <see cref="Parameters" /> class.
        /// </summary>
        public Parameters()
        {
            OrganizationUrl = Settings.Default.OrgUrl;
            UserDomain = Settings.Default.Domain;
            UserLogin = Settings.Default.Login;
            UserPassword = Settings.Default.Password;
            CheckInterval = Settings.Default.CheckInterval;
            DefaultExportPath = Settings.Default.DefaultExportPath;
            CrmConnectionString = Settings.Default.CrmConnectionString;

        }
        #endregion

        #region Save
        /// <summary>
        /// </summary>
        public void Save()
        {
            Settings.Default.OrgUrl = OrganizationUrl;
            Settings.Default.Domain = UserDomain;
            Settings.Default.Login = UserLogin;
            Settings.Default.Password = UserPassword;
            Settings.Default.CheckInterval = CheckInterval;
            Settings.Default.DefaultExportPath = DefaultExportPath;
            Settings.Default.CrmConnectionString = CrmConnectionString;
            Settings.Default.Save();
        }
        #endregion
    }
}
